﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="messageslist.aspx.cs" Inherits="UI.system.page.news.messageslist" %>

<%@ Import Namespace="Model" %>
<%@ Import Namespace="DAL" %>

<style>
    .layer-page{bottom:0!important;}
    .layui-form{padding-bottom:21px}
    .layui-btn-sm {height:30px;line-height:30px; padding:0 10px;}
    </style>
	<form class="layui-form" style="padding-left:0px;">
    <div class="layui-form">
    <table class="layui-table">
    <colgroup>
      <col width="50">
      <col width="130">
      <col width="30">
    </colgroup>
    <thead>
      <tr>
        <th>留言用户</th>
        <th>留言内容</th>
        <th>操作</th>
      </tr>
    </thead>
    <tbody id="layer-table">
        <tr><td colspan="20" class="center">数据加载中...</td></tr>
    </tbody>
    </div>
     <script id="data-table" type="text/html">
     {{#  layui.each(d, function(index, item){ }}
      <tr>
        <td>{{item.UserName}}</td>
        <td>{{item.Message}}</td>
        <td style="line-height:30px;">
        <a class="layui-btn layui-btn-mini layui-btn-danger" onclick="Delete_Msg(this,{{item.ID}})">删除</a>
        </td>
      </tr>
      {{#  }); }}
      </script>
    </table>
    </div>
    <div id="layer-page" class="layer-page"></div>
    </form>
    <script>
        layui.use(['laytpl','laypage', 'element'], function () {
            $ = layui.jquery, laytpl = layui.laytpl,laypage = layui.laypage;;
            Init_Pager(1);
        });

        function Init_Pager(pageindex) {
            var data = {};
            data.act = "Find_AllMessage";
            data.startindex = pageindex;
            data.articleid = <%=articleid %>;
            data.pagesize=3;
            data.sign = GetSign(data.act);
            Loading();
            Ajax.Post("/tools/Admin.ashx", data, function (r) {
                var json = $.parseJSON(r);
                if (json.state) {
                    Pager(json.data.list, json.data.count);
                }
                else {
                    LayerBox.Error(json.msg);
                }
            });
        };

        function Delete_Msg(o, id) {
            LayerBox.Confirm("您确定要删除吗？", function () {
                Delete_Table(o, id, "Delete_Msg");
            });
        };

        function Save_News(id) {
            LayerBox.Loading();
            Ajax.Get("/system/page/news/newsadd.aspx?id=" + id, function (html) {
                LayerBox.Close.ByAll();
                var title = id == 0 ? "新增" : "修改";
                window.parent.LayerBox.Show(title + "活动", html, 590, 710, null, function (form) {
                    var data = form;
                    data.act = "Save_News";
                    data.id = id;
                    data.content = ue.getContent();
                    data.sign = GetSign(data.act);
                    data.coverimg = window.parent.$(".img_container img").attr("src");
                    LayerBox.Loading();
                    Ajax.Post("/tools/Admin.ashx", data, function (r) {
                        var json = $.parseJSON(r);
                        if (json.state) {
                            LayerBox.Success(json.msg, 500, function () {
                                LayerBox.Close.ByAll();
                                if (id == 0) {
                                    $(".layui-laypage").remove();
                                    Init_Pager(1);
                                } else {
                                    var currpage = 1;
                                    if ($(".layui-laypage-curr em").length > 0) {
                                        currpage = $(".layui-laypage-curr em")[1].innerHTML;
                                    }
                                    Init_Pager(currpage);
                                }
                            });
                        }
                        else {
                            LayerBox.Error(json.msg);
                        }
                    });
                });
                window.parent.UE.delEditor('context');
                var ue = window.parent.UE.getEditor('context');
                var upload = new window.parent.Upload_File("upload_img");
                upload.swfu.handle = "upload_active";
            });
        };


        function Save_Messages(id) {
            LayerBox.Loading();
            Ajax.Get("/system/page/news/newsadd.aspx?id=" + id, function (html) {
                LayerBox.Close.ByAll();
                var title = id == 0 ? "新增" : "修改";
                window.parent.LayerBox.Show(title + "活动", html, 590, 710, null, function (form) {
                    var data = form;
                    data.act = "Save_Message";
                    data.id = id;
                    data.content = ue.getContent();
                    data.sign = GetSign(data.act);
                    data.coverimg = window.parent.$(".img_container img").attr("src");
                    LayerBox.Loading();
                    Ajax.Post("/tools/Admin.ashx", data, function (r) {
                        var json = $.parseJSON(r);
                        if (json.state) {
                            LayerBox.Success(json.msg, 500, function () {
                                LayerBox.Close.ByAll();
                                if (id == 0) {
                                    $(".layui-laypage").remove();
                                    Init_Pager(1);
                                } else {
                                    var currpage = 1;
                                    if ($(".layui-laypage-curr em").length > 0) {
                                        currpage = $(".layui-laypage-curr em")[1].innerHTML;
                                    }
                                    Init_Pager(currpage);
                                }
                            });
                        }
                        else {
                            LayerBox.Error(json.msg);
                        }
                    });
                });
                window.parent.UE.delEditor('context');
                var ue = window.parent.UE.getEditor('context');
                var upload = new window.parent.Upload_File("upload_img");
                upload.swfu.handle = "upload_active";
            });
        };
    </script>